<template>
  <div class="editor">
    <textarea :value="input" @input="update($event)"></textarea>
    <div v-html="compliedMarkdown" class="code"></div>
  </div>
</template>
<script>
  import marked from 'marked'
  import _ from 'lodash'
  export default{
    data() {
      return {
        input: '#Hello'
      }
    },
    computed: {
      compliedMarkdown() {
        return marked(this.input, {sanitize: true})
      }
    },
    methods: {
      update: _.debounce(function(e) {
        this.input = e.target.value
      }, 300)
    }
  }
</script>
<style lang="scss" scoped>
.editor{
  height: 600px;
  color: #333;
  textarea,div{
    display: inline-block;
    width: 49%;
    height: 100%;
    vertical-align: top;
    box-sizing: border-box;
    padding: 0 20px;
    border: 1px solid #ccc;
  }
}
textarea{
  border: none;
  border-right: 1px solid #ccc;
  resize: none;
  outline: none;
  background:#f6f6f6;
  font-size: 14px;
}
.code{
  color:#f66;
}
</style>

